package cn.itcast.service.feedback.impl;

import cn.itcast.dao.feedback.FeedBackDao;
import cn.itcast.domain.feedback.Feedback;
import cn.itcast.service.feedback.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class FeedbackServiceImp implements FeedbackService {
    @Autowired
    private FeedBackDao feedBackDao;
    @Override
    public void wirteFk(Feedback feedback) {
        feedback.setId(UUID.randomUUID().toString());
        feedback.setStat(0);//未读
        feedback.setCreate_time(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        feedBackDao.wirteFk(feedback);
    }

    @Override
    public List<Feedback> showlist(Feedback feedback) {
        List<Feedback>  list=  feedBackDao.showlist(feedback);
        return list;
    }

    @Override
    public Feedback findByFeed(String id) {
        Feedback byFeed = feedBackDao.findByFeed(id);
        Feedback feedback = new Feedback();
        feedback.setStat(1);//已读
        feedback.setId(id);
        feedBackDao.update(feedback);
        return   byFeed;
    }

    @Override
    public List<Feedback> showSass(Feedback feedback) {
        System.out.println(feedback+"55");
        List<Feedback>  list=  feedBackDao.showSass(feedback);
        return list;
    }

    @Override
    public void delete(String[] id) {
        for (String s : id) {
                feedBackDao.delete(s);
        }
    }
}
